
#ifndef MATERIAL_H_
#define MATERIAL_H_

#include "libmath.h"

namespace p2 {

/*
 * REF: http://ffden-2.phys.uaf.edu/211_fall2002.web.dir/ben_townsend/staticandkineticfriction.htm
 * Surfaces						muStatic	muKinetic
 * -----------------------------------------------------
 * Steel on steel				0.74		0.57
 * Glass on glass				0.94		0.40
 * Metal on Metal (lubricated)	0.15		0.06
 * Ice on ice					0.10		0.03
 * Teflon on Teflon				0.04		0.04
 * Tire on concrete				1.00		0.80
 * Tire on wet road				0.60		0.40
 * Tire on snow					0.30		0.20
 */

/*
 * REF: http://www.physics.usyd.edu.au/~cross/PUBLICATIONS/BallBounce.pdf
 */

class Element;
class p2Material: public RealTimeType
{
public:
	p2Material()
	:	_muStatic(0.f), _muKinetic(0.f), _cor(0.f)
	{
	}
	p2Material(real muStatic, real muKinetic, real cor)
	:	_muStatic(muStatic), _muKinetic(muKinetic), _cor(cor)
	{
	}
	virtual ~p2Material()
	{
	}
	static inline real combineFriction(p2Material const& m0, p2Material const& m1)
	{
		return Math<real>::Max(m0._muKinetic, m1._muKinetic);
	}
	inline real muStatic()
	{
		return _muStatic;
	}
	inline real muKinetic()
	{
		return _muKinetic;
	}
	static inline real combineRestitution(real cor0, real cor1)
	{
		return Math<real>::Min(cor0, cor1);
	}
	inline real cor()
	{
		return _cor;
	}

private:
	/*
	 * REF: http://en.wikipedia.org/wiki/Greek_letters_used_in_mathematics,_science,_and_engineering
	 */
//	real _density;
	real _muStatic;
	real _muKinetic;
	/*
	 * REF: http://en.wikipedia.org/wiki/Coefficient_of_restitution
	 * REF: http://www.sixtysymbols.com/videos/restitution.htm
	 */
	real _cor;
//	real _E;	// elasticity
//	real _bouciness;
};

}

#endif	//MATERIAL_H_
